<template>
<div>
  <div class="myheader">
    <nav>
      <div class="navbar-logo"><span class="iconfont icon-zuojiantou" @click="fanhui"></span></div>
      <div class="navbar-title">猫眼电影</div>
      <div class="navbar-button">
        <span class="iconfont icon-nav" v-if="this.$route.path !== '/login'"></span>
      </div>
    </nav>
  </div>
   <div class="movie_detail">
    <p>id:{{ id }}</p>
    <div class="movie_info">
      <div class="poster">
        <img :src="movieItemList.img" alt="" />
      </div>
      <div class="mov-con">
        <p>{{ movieItemList.nm }}</p>
        <p>{{ movieItemList.cat }}</p>
        <p>{{ movieItemList.star }}</p>
        <p>{{ movieItemList.pubDesc }}/{{ movieItemList.dur }}分钟</p>
      </div>
    </div>
    <div>
      <p>想看:{{ movieItemList.wish }}</p>
      <p>评分:{{ movieItemList.mk }}</p>
    </div>
  </div>
</div>
 
</template>

<script>
import axios from "axios";
export default {
  name: "MovieItem",
  data() {
    return {
      id: "",
      movieItemList: [],
      hotlist: [],
    };
  },
   methods:{
    fanhui(){
      this.$router.go(-1)
    }
  },
  mounted() {
    //获取从首页传过来的参数
    console.log(this.$route.params);
    this.id = this.$route.params.id;
    axios
      .get(
        "/api/mmdb/movie/v3/list/hot.json?ct=%E6%B7%B1%E5%9C%B3&ci=30&channelId=4",
        { ct: "深圳", ci: 30, channelId: 4 }
      )
      .then((res) => {
        this.hotlist = res.data.data.hot;
        this.movieItemList = this.hotlist.find((item) => {
          return item.id == this.id;
        });
        console.log(this.movieItemList);
        console.log(this.hotlist);
      });
  },
};
</script>

<style lang="less">
.myheader {
  width: 100%;
  background: #e54847;
  color: #fef9f9;
  text-align: center;
  line-height: 1.0133rem;
  height: 1.0133rem;

  nav {
    display: flex;

    .navbar-logo {
      width: 20%;
      height: 1.0133rem;
      display: block;
      .icon-zuojiantou{
        position: absolute;
      left: 15px;
      }
    }

    .navbar-title {
      width: 60%;
      height: 1.0133rem;
      display: block;
      font-size: 18px;
    }

    .navbar-button {
      width: 20%;
      text-align: right;
      font-size: 30px;

      .icon-nav {
        position: relative;
        font-size: 25px;
        right: 5px;
      }
    }
  }
}
.movie_detail {
  font-size: 20px;
  .movie_info {
    width: 100%;
    .poster {
      width: 40%;
      img {
        width: 100%;
      }
    }
    .mov-con {
      width: 60%;
    }
    display: flex;
  }
}
</style>